There is a randomized algorithm running in time that, with probability determines if an -bit integer is prime.
MillerRabin(n) If and is even, return composite. /* Factor as where is odd. */ while is even end /* Done. . */ Choose uniformly at random. Compute each of the numbers . If , return composite. for If and , return composite. end /* Done checking for fake square roots. */ Return probably prime.
See also: PRIMES is in P paper
References: